<html ng-app="app">

<head>
    <meta charset="utf-8">
    <meta name="viewport"
          content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <meta name="format-detection" content="telephone=no"/>
    <meta name="msapplication-tap-highlight" content="no"/>
    <script type="text/javascript" src="/files/jquery-1.9.1.min.js"></script>
    <title>查询页面</title>
    <script src="/config.js"></script>
</head>
<body>
<div>
    <div style="position: relative; text-align:center;height: 15vw; word-wrap: break-word; word-break: break-all; color: rgb(0, 0, 0); background-color: white; border-width: 0px; border-top-style: solid; border-color: rgb(230, 230, 230);">
        <input type="text" maxlength="10" class='J_security_code' placeholder="请输入房间号 不输入查询所有房间"
               style="padding: 0px 12px; position: absolute; top: 1vw; left: 0vw; width: 72vw; height: 12vw; line-height: 6.5vw; border-style: solid; border-width: 1px; border-radius: 0.5vh; border-color: rgb(240, 240, 240); background-color: rgb(240, 240, 240); font-size: 4vw; -webkit-appearance: none;">
        <div style="position: relative; top: 0.5vh;left: 80vw; width: 15vw; line-height: 11vw; font-size: 4vw; display: flex; border-radius: 2vw;">
            <div onclick="sendsearchsys()"
                 style="display: block; -webkit-box-flex: 1; flex: 1 1 0%; text-decoration: none; -webkit-tap-highlight-color: transparent; position: relative; margin-bottom: 0px; color: rgb(255, 255, 255); border-width: 0px; border-top-style: solid; border-color: rgb(230, 230, 230); background-color: rgb(64, 112, 251); border-radius: 1vw;">
                查询
            </div>
        </div>
    </div>

</div>
<div class="searchsys"
     style="position:absolute;top: 10%;left: 6%;right: 6%;bottom: 3%;border-radius:1vh;z-index:100;display:block;">
    <div style="background:#fff; width:100%;height:100%;">
        <div class="searchsys_Title" style="color: rgb(64, 112, 251);width: 100%; font-size: 2vh; text-align:center;">
            巡查系统
        </div>
        <div class="searchsys_content"
             style="width: auto; font-size: 2vh; text-align:center; margin:0 2vh;position:relative;">
        </div>
    </div>
</div>
<script>
    function sendsearchsys(id = '') {
        if (id === '') {
            var securityCode = $(".J_security_code").val();
        } else {
            var securityCode = id;
        }
        if (securityCode === '') {
            securityCode = '0';
        }
        if (typeof (securityCode) !== 'string') {
            securityCode = securityCode.toString();
        }
        if (securityCode.length > 0) {
            zn_ajax('/index/supervise/xunchaquery',{'e': securityCode},
                function (e) {
                    if (e.result == 0) {
                        var a = e.data;
                        $('.searchsys_content').html('');
                        if (a.length > 0) {
                            for (var j = 0, len = a.length; j < len; j++) {
                                if (a[j].open == 2) {
                                    $('.searchsys_content').append('<p style="margin:0;height:4vh;line-height:4vh;"><span style="position:absolute;left:0;"><img src="' + a[j].img + '" style="width:6vw;height:6vw;"></span><span>' + a[j].nickname + '</span><span style="color: rgb(64, 112, 251);position:absolute;right:0;z-index:1000;">' + a[j].isopen + '</span></p>');
                                } else {
                                    $('.searchsys_content').append('<p style="margin:0;height:4vh;line-height:4vh;"><span style="position:absolute;left:0;"><img src="' + a[j].img + '" style="width:6vw;height:6vw;"></span><span>' + a[j].nickname + '</span><span style="color: #df0000;position:absolute;right:0;z-index:1000;" onclick="overcontrol(' + a[j].id + ');">' + a[j].isopen + '</span></p>');
                                }
                            }
                        }
                    } else {
                        if (e.result == 10001) {
                            $('.searchsys_content').html('');
                            $('.searchsys_content').append('<p >你没有此权限</p>');
                        } else {
                            if (e.result == 1) {
                                var a = e.data;
                                $('.searchsys_content').html('');
                                if (a.length > 0) {
                                    for (var j = 0, len = a.length; j < len; j++) {
                                        $('.searchsys_content').append('<p onclick="sendsearchsys(' + a[j].id + ')" style="margin:0;height:4vh;line-height:4vh;"><span style="position:absolute;left:0;">房间:' + a[j].id + '</span><span>' + a[j].name + '</span><span>' + a[j].time + '</span><span style="color: rgb(64, 112, 251);position:absolute;right:0;z-index:1000;">人数:' + a[j].users + '</span</p>');
                                    }
                                }else{
                                    $('.searchsys_content').html('');
                                    $('.searchsys_content').append('<p >无进行房间</p>');
                                }
                            } else {
                                $('.searchsys_content').html('');
                                $('.searchsys_content').append('<p >房间不存在或者已经关闭</p>');
                            }
                        }
                    }
                });
        }
    }

    function overcontrol(id) {
        zn_ajax('/index/supervise/overcontrol',{'id': id},function (data) {
                if (data.result == 1) {
                    $('.searchsys_content').html('');
                    $('.searchsys_content').append('<p >关闭成功</p>');
                } else {
                    $('.searchsys_content').html('');
                    $('.searchsys_content').append('<p >关闭失败</p>');
                }
            });
    }


    function zn_ajax(url, data, callback) {
        $.ajax({
            type: "post",
            url: JONO_HOST + url,
            dataType: 'JSON',
            data: data,
            async: false,
            success: callback,
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                msg(errorThrown);
            },
            beforeSend : function(request) {
                request.setRequestHeader("Authorization",window.localStorage.getItem("token"));
            },
        });
    }

</script>
</body>
</html>


